#! env python
#-*- coding: utf-8 -*-

import requests

# Gitee API Base URL
API_URL = 'https://gitee.com/api/v5'

def get_issue_timeline(issue_number, api_token=None):
    if api_token is None:
        import os
        api_token = os.environ['GITEE_TOKEN']
    headers = { "Authorization": f"token {api_token}" }
    response = requests.get(f"{API_URL}/issues/{issue_number}/timeline", headers=headers)
    if response.status_code == 200:
        print("获取 Issue 记录成功:", response.json())
    else:
        print(f"请求失败，状态码：{response.status_code}, 原因: {response.text}")


if __name__ == '__main__':
    # Issue 编号和 API Token
    issue_number = 'YOUR_ISSUE_NUMBER'
    get_issue_timeline(issue_number)
